<template>
    <div class="login-container">
      <h2>登录</h2>
      <form @submit.prevent="handleSubmit">
        <div class="form-group">
          <label for="username">用户名</label>
          <input
            type="text"
            id="username"
            v-model="form.username"
            placeholder="请输入用户名"
            required
          />
        </div>
        <div class="form-group">
          <label for="password">密码</label>
          <input
            type="password"
            id="password"
            v-model="form.password"
            placeholder="请输入密码"
            required
          />
        </div>
        <button type="submit"   @click="openCenter">登录</button>
      </form>
    </div>
  </template>
  <script setup>
  import { ref } from 'vue';
  import { useRouter } from 'vue-router'; // 如果使用了 Vue Router
  import { ElMessage } from 'element-plus'
  // 定义表单数据
  const form = ref({
    username: '',
    password: '',
  });
  const router = useRouter(); // 如果使用了 Vue Router
  // 处理表单提交
  const handleSubmit = () => {
    if (form.value.username=="admin" && form.value.password==123456) {
      alert(`用户名: ${form.value.username}, 密码: ${form.value.password},成功登陆`);
      // 通常在这里调用 API 进行登录验证
      // 假设登录成功，跳转到主页
      router.push('/about'); // 如果使用了 Vue Router
    } else {
      alert('请正确输入用户名和密码');
    }
  };
  </script>
  <style scoped>
  .login-container {
    max-width: 300px;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
  }
  .form-group {
    margin-bottom: 15px;
  }
  label {
    display: block;
    margin-bottom: 5px;
  }
  input {
    width: 100%;
    padding: 8px;
    box-sizing: border-box;
  }
  button {
    width: 100%;
    padding: 10px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
  }
  button:hover {
    background-color: #218838;
  }
  </style>
  